<template>
  <div class="app-container">
    <div class="search-container">
      <el-form inline>
        <el-form-item label="名称">
          <el-input />
        </el-form-item>
        <el-button type="primary">搜索</el-button>
        <!-- <el-button type="primary" @click="operate('add')">新增</el-button> -->
        <!-- <el-button type="primary">导入</el-button>
        <el-button type="primary">导出</el-button> -->
      </el-form>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="老人姓名" width="140px" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="编号" align="center" width="140px">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column label="服务项目" width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.type }}
        </template>
      </el-table-column>
      <el-table-column label="补贴金额（元）" width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.price }}
        </template>
      </el-table-column>
      <el-table-column label="补贴比例" width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.ratio }}
        </template>
      </el-table-column>
      <el-table-column label="备注" min-width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.remark }}
        </template>
      </el-table-column>
      <!-- <el-table-column
        class-name="status-col"
        label="服务状态"
        width="110"
        align="center"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{
            scope.row.status | statusFilterLabel
          }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="处理时间" width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.display_time }}
        </template>
      </el-table-column> -->
      <el-table-column label="操作" width="180" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" size="mini">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      :visible.sync="dialogVisible"
      :title="title"
      width="800px"
      center
    >
      <el-form ref="form" :model="form" label-width="120px" inline size="small">
        <div>
          <span class="title">基础信息 </span>
        </div>
        <el-form-item label="姓名">
          <el-input v-model="form.name" style="width:200px" />
        </el-form-item>
        <el-form-item label="出生日期">
          <el-date-picker
            v-model="form.date1"
            type="date"
            placeholder="选择日期"
            style="width:200px"
          />
        </el-form-item>
        <el-form-item label="性别">
          <el-select v-model="form.person" placeholder="" style="width:200px">
            <el-option
              v-for="(item, index) in personList"
              :key="index"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="证件号">
          <el-input v-model="form.card_id" style="width:200px" />
        </el-form-item>
        <el-form-item label="联系人">
          <el-input v-model="form.person" style="width:200px" />
        </el-form-item>
        <el-form-item label="联系方式">
          <el-input v-model="form.phone" style="width:200px" />
        </el-form-item>

        <div>
          <span class="title">健康状况</span>
        </div>
        <el-form-item label="身高">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="体重">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="血压">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="心率">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="否有慢性病">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="残疾">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="疾病史">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>
        <el-form-item label="用药情况" style="width:100%" class="medical-row">
          <el-table :data="medicalData" border fit highlight-current-row>
            <el-table-column label="药物名称"></el-table-column>
            <el-table-column label="剂量"></el-table-column>
            <el-table-column label="用法"></el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item label="过敏史">
          <el-input v-model="form.value" style="width:200px" />
        </el-form-item>

        <div>
          <span class="title">健康状况</span>
        </div>
        <el-form-item label="饮食习惯">
          <el-input type="textarea" v-model="form.value" style="width:500px" />
        </el-form-item>
        <el-form-item label="运动习惯">
          <el-input type="textarea" v-model="form.value" style="width:500px" />
        </el-form-item>
        <el-form-item label="睡眠习惯">
          <el-input type="textarea" v-model="form.value" style="width:500px" />
        </el-form-item>

        <div>
          <span class="title">服务需求</span>
        </div>
        <el-form-item label="生活照料" style="width:100%">
          <el-checkbox-group v-model="checkList">
            <el-checkbox label="日常清洁"></el-checkbox>
            <el-checkbox label="洗衣做饭"></el-checkbox>
            <el-checkbox label="购物陪同"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="医疗护理" style="width:100%">
          <el-checkbox-group v-model="checkList">
            <el-checkbox label="定期体检"></el-checkbox>
            <el-checkbox label="康复治疗"></el-checkbox>
            <el-checkbox label="疾病管理"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="精神慰藉" style="width:100%">
          <el-checkbox-group v-model="checkList">
            <el-checkbox label="陪伴聊天"></el-checkbox>
            <el-checkbox label="心理咨询"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>

        <div>
          <span class="title">其他信息</span>
        </div>

        <el-form-item label="家庭结构">
          <el-input type="textarea" v-model="form.value" style="width:500px" />
        </el-form-item>
        <el-form-item label="居住环境">
          <el-input type="textarea" v-model="form.value" style="width:500px" />
        </el-form-item>
        <div>
          在进行老人信息采集时，应遵循相关法律法规和伦理规范，确保信息的真实性和准确性。同时，应注意保护老人的隐私权益，避免泄露其敏感信息。
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="onSubmit">提交</el-button>
        <el-button @click="onCancel">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getList } from "@/api/table";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        0: "success",
        1: "gray",
        2: "danger",
        3: "warning"
      };
      return statusMap[status];
    },
    statusFilterLabel(status) {
      const statusMap = {
        0: "进行中",
        1: "已完成",
        2: "暂停",
        3: "待启动"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      data: [
        {
          name: "张三",
          age: "46",
          sex: "男",
          person: "李响",
          phone: "137****8980",
          card_id: "3307********8980",
          display_time: "2023-12-24 16:10:10",
          id: "2104623",
          type: "居家清洁",
          price: "100",
          ratio: "20"
        },
        {
          name: "张三",
          age: "46",
          sex: "男",
          person: "李响",
          phone: "137****8980",
          card_id: "3307********8980",
          display_time: "2023-12-24 16:10:10",
          id: "2104623",
          type: "维持生命体征",
          price: "3000",
          ratio: "60"
        },
        {
          name: "张三",
          age: "46",
          sex: "男",
          person: "李响",
          phone: "137****8980",
          card_id: "3307********8980",
          display_time: "2023-12-24 16:10:10",
          id: "2104623",
          type: "居家清洁",
          price: "100",
          ratio: "20"
        }
      ],
      dialogVisible: false,
      title: "老人信息",
      personList: [{ label: "张三", value: "0" }],
      numList: [
        { label: "每年", value: "0" },
        { label: "每月", value: "1" },
        { label: "每日", value: "2" }
      ],
      typeList: [
        { label: "消防安全", value: "0" },
        { label: "食堂安全", value: "1" },
        { label: "护工查房", value: "2" }
      ],
      form: {},
      checkList: ["日常清洁", "定期体检", "心理咨询"]
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.listLoading = true;
      this.list = this.data;
      this.listLoading = false;
      // getList().then(response => {
      //   this.list = response.data.items
      //   this.listLoading = false
      // })
    },
    operate(type) {
      if (type === "add") {
        this.dialogVisible = true;
      }
    },
    detail(row) {
      this.form = row;
      this.dialogVisible = true;
    },
    fileDetail(row) {
      this.$router.push({ name: "OldDetail" });
    },
    onSubmit() {
      this.$message("submit!");
    },
    onCancel() {
      this.dialogVisible = false;
    }
  }
};
</script>
<style scoped lang="scss">
.line {
  text-align: center;
}
.title {
  margin-bottom: 20px;
  font-weight: 600;
  left: -5px;
}
.title::before {
  // content: "";
  // display: inline-block;
  // width: 2px;
  // height: 20px;
  // background: pink;
  // margin: 0 5px;

  content: "";
  width: 3px;
  height: 16px;
  position: absolute;
  margin: 0 -8px;
  background: rgb(32, 125, 255);
}
.medical-row {
  ::v-deep.el-form-item__content {
    width: 80%;
  }
}
</style>
